package com.tuantuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuantuan.common.base.BaseServiceImpl;
import com.tuantuan.common.base.common.CommonConstant;
import com.tuantuan.common.base.param.QueryParam;
import com.tuantuan.model.entity.LiAgentDO;
import com.tuantuan.mapper.LiAgentMapper;
import com.tuantuan.service.ILiAgentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 服务 实现类
 * </p>
 *
 * @author: 王钦民
 * @date : 2020-10-29
 * @description: 仰天大笑出门去，我辈岂是蓬蒿人
 */
@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class LiAgentServiceImpl extends BaseServiceImpl<LiAgentMapper, LiAgentDO> implements ILiAgentService {

    @Autowired
    private LiAgentMapper liAgentMapper;

    @Override
    public Page<LiAgentDO> listPageLiAgent(QueryParam queryParam) {
        Page<LiAgentDO> page = new Page<>(queryParam.getCurrent(), queryParam.getSize());
        // 根据时间倒序排序
        page.addOrder(OrderItem.desc(CommonConstant.CREATE_TIME));
        // mybatis-plus条件构造器
        QueryWrapper queryWrapper = likeSearchMap(queryParam);
        // 开始查询
        Page<LiAgentDO> liAgentPage = baseMapper.selectPage(page, queryWrapper);
        return liAgentPage;
    }


}

